﻿package 
{

	import flash.display.MovieClip;
	import com.devilcat.dt.Gamedt;
	import com.worlize.websocket.*;
	import flash.utils.ByteArray;
	import com.devilcat.ws.*;
	import flash.system.Security;
	import flash.events.MouseEvent;

	public class Worlize extends MovieClip
	{
		//var websocket:WebSocket;
		
		public function Worlize()
		{
			//Security.loadPolicyFile("https://dl.dropboxusercontent.com/u/38617128/FLA/crossdomain.xml");
//			Security.allowDomain("*");
//			Gamedt.mainClip=this;
//			btnLogin.addEventListener(MouseEvent.CLICK,function(){var wTest:Loginws=new Loginws("Miiu","123");});
//			btnLoadpokemon.addEventListener(MouseEvent.CLICK,function(){var wTest:Pokemonws=new Pokemonws(16);});
//			btnLoadInfor.addEventListener(MouseEvent.CLICK,function(){var wTest:PlayerInforws=new PlayerInforws(36,"username");});
//			btnLoadUserPokemon.addEventListener(MouseEvent.CLICK,function(){var wTest:UserPokemonws=new UserPokemonws(36);});
			btnLoadEvent.addEventListener(MouseEvent.CLICK,function(){var wTest:UserEventws=new UserEventws(36);});
			
/*			websocket = new WebSocket("ws://127.0.0.1:44","*","chat-protocol");
			websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
			websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
			websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
			websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
			websocket.connect();*/
		}
/*		function handleWebSocketOpen(event:WebSocketEvent):void
		{
			trace("Connected");
			websocket.sendUTF("Hello World!\n");
			var binaryData:ByteArray = new ByteArray();
			binaryData.writeUTF("Hello as Binary Message!");
			websocket.sendBytes(binaryData);
		}

		function handleWebSocketClosed(event:WebSocketEvent):void
		{
			trace("Disconnected");
		}

		private function handleConnectionFail(event:WebSocketErrorEvent):void
		{
			trace("Connection Failure: " + event.text);
		}

		function handleWebSocketMessage(event:WebSocketEvent):void
		{
			if (event.message.type === WebSocketMessage.TYPE_UTF8)
			{
				trace("Got message: " + event.message.utf8Data);
			}
			else if (event.message.type === WebSocketMessage.TYPE_BINARY)
			{
				trace("Got binary message of length " + event.message.binaryData.length);
			}
		}*/
	}
}